adapt the record format with the input format
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28302 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -651,14 +651,16 @@ RecorderWindow::Record(BMessage * message)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Reserve space on disk (creates fewer fragments)
|
// Reserve space on disk (creates fewer fragments)
|
||||||
err = fRecFile.SetSize(seconds*4*48000LL);
|
err = fRecFile.SetSize(seconds * fRecordFormat.u.raw_audio.channel_count
|
||||||
|
* fRecordFormat.u.raw_audio.frame_rate * (fRecordFormat.u.raw_audio.format & 0xf));
|
||||||
if (err < B_OK) {
|
if (err < B_OK) {
|
||||||
ErrorAlert("record a sound that long", err);
|
ErrorAlert("record a sound that long", err);
|
||||||
fRecEntry.Remove();
|
fRecEntry.Remove();
|
||||||
fRecEntry.Unset();
|
fRecEntry.Unset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fRecLimit = seconds*4*48000LL;
|
fRecLimit = (off_t)(seconds * fRecordFormat.u.raw_audio.channel_count
|
||||||
|
* fRecordFormat.u.raw_audio.frame_rate * (fRecordFormat.u.raw_audio.format & 0xf));
|
||||||
fRecSize = 0;
|
fRecSize = 0;
|
||||||
|
|
||||||
fRecFile.Seek(sizeof(struct wave_struct), SEEK_SET);
|
fRecFile.Seek(sizeof(struct wave_struct), SEEK_SET);
|
||||||
@@ -917,9 +919,8 @@ RecorderWindow::MakeRecordConnection(const media_node & input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get a format, any format.
|
// Get a format, any format.
|
||||||
media_format fmt;
|
fRecordFormat.u.raw_audio = fAudioOutput.format.u.raw_audio;
|
||||||
fmt.u.raw_audio = fAudioOutput.format.u.raw_audio;
|
fRecordFormat.type = B_MEDIA_RAW_AUDIO;
|
||||||
fmt.type = B_MEDIA_RAW_AUDIO;
|
|
||||||
|
|
||||||
// Tell the consumer where we want data to go.
|
// Tell the consumer where we want data to go.
|
||||||
err = fRecordNode->SetHooks(RecordFile, NotifyRecordFile, this);
|
err = fRecordNode->SetHooks(RecordFile, NotifyRecordFile, this);
|
||||||
@@ -930,7 +931,7 @@ RecorderWindow::MakeRecordConnection(const media_node & input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Using the same structs for input and output is OK in BMediaRoster::Connect().
|
// Using the same structs for input and output is OK in BMediaRoster::Connect().
|
||||||
err = fRoster->Connect(fAudioOutput.source, fRecInput.destination, &fmt, &fAudioOutput, &fRecInput);
|
err = fRoster->Connect(fAudioOutput.source, fRecInput.destination, &fRecordFormat, &fAudioOutput, &fRecInput);
|
||||||
if (err < B_OK) {
|
if (err < B_OK) {
|
||||||
CONNECT((stderr, "RecorderWindow::MakeRecordConnection(): failed to connect sound recorder to audio input node.\n"));
|
CONNECT((stderr, "RecorderWindow::MakeRecordConnection(): failed to connect sound recorder to audio input node.\n"));
|
||||||
tsobj->Release();
|
tsobj->Release();
|
||||||
@@ -978,11 +979,14 @@ RecorderWindow::StopRecording()
|
|||||||
header.format_chunk.fourcc = FOURCC('f','m','t',' ');
|
header.format_chunk.fourcc = FOURCC('f','m','t',' ');
|
||||||
header.format_chunk.len = sizeof(header.format);
|
header.format_chunk.len = sizeof(header.format);
|
||||||
header.format.format_tag = 1;
|
header.format.format_tag = 1;
|
||||||
header.format.channels = 2;
|
header.format.channels = fRecordFormat.u.raw_audio.channel_count;
|
||||||
header.format.samples_per_sec = 48000;
|
header.format.samples_per_sec = (uint32)fRecordFormat.u.raw_audio.frame_rate;
|
||||||
header.format.avg_bytes_per_sec = 48000 * 4;
|
header.format.avg_bytes_per_sec = (uint32)(fRecordFormat.u.raw_audio.frame_rate
|
||||||
header.format.block_align = 4;
|
* fRecordFormat.u.raw_audio.channel_count
|
||||||
header.format.bits_per_sample = 16;
|
* (fRecordFormat.u.raw_audio.format & 0xf));
|
||||||
|
header.format.bits_per_sample = (fRecordFormat.u.raw_audio.format & 0xf) * 8;
|
||||||
|
header.format.block_align = (fRecordFormat.u.raw_audio.format & 0xf)
|
||||||
|
* fRecordFormat.u.raw_audio.channel_count;
|
||||||
header.data_chunk.fourcc = FOURCC('d','a','t','a');
|
header.data_chunk.fourcc = FOURCC('d','a','t','a');
|
||||||
header.data_chunk.len = fRecSize;
|
header.data_chunk.len = fRecSize;
|
||||||
fRecFile.Seek(0, SEEK_SET);
|
fRecFile.Seek(0, SEEK_SET);
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ private:
|
|||||||
BtnState fButtonState;
|
BtnState fButtonState;
|
||||||
BEntry fRecEntry;
|
BEntry fRecEntry;
|
||||||
|
|
||||||
|
media_format fRecordFormat;
|
||||||
|
|
||||||
BFile fRecFile;
|
BFile fRecFile;
|
||||||
off_t fRecLimit;
|
off_t fRecLimit;
|
||||||
off_t fRecSize;
|
off_t fRecSize;
|
||||||
|
|||||||
Reference in New Issue
Block a user