Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
b9f64fe1
An error occurred while fetching merge requests data.
Commit
b9f64fe1
authored
8 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/haiku: embed "format" into the HaikuOutput class
Avoid one level of dynamic allocation.
parent
dd072912
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
30 deletions
+22
-30
HaikuOutputPlugin.cxx
src/output/plugins/HaikuOutputPlugin.cxx
+22
-30
No files found.
src/output/plugins/HaikuOutputPlugin.cxx
View file @
b9f64fe1
...
...
@@ -52,7 +52,7 @@ class HaikuOutput {
size_t
write_size
;
media_raw_audio_format
*
format
;
media_raw_audio_format
format
;
BSoundPlayer
*
sound_player
;
sem_id
new_buffer
;
...
...
@@ -129,18 +129,11 @@ finalize_application()
}
inline
bool
HaikuOutput
::
Configure
(
const
ConfigBlock
&
block
,
Error
&
error
)
HaikuOutput
::
Configure
(
const
ConfigBlock
&
block
,
Error
&
)
{
/* XXX: by default we should let the MediaKit propose the buffer size */
write_size
=
block
.
GetBlockValue
(
"write_size"
,
4096u
);
format
=
(
media_raw_audio_format
*
)
malloc
(
sizeof
(
media_raw_audio_format
));
if
(
format
==
nullptr
)
{
haiku_output_error
(
error
,
B_NO_MEMORY
);
return
false
;
}
return
true
;
}
...
...
@@ -187,7 +180,6 @@ HaikuOutput::DoClose()
HaikuOutput
::~
HaikuOutput
()
{
free
(
format
);
delete_sem
(
new_buffer
);
delete_sem
(
buffer_done
);
...
...
@@ -235,53 +227,53 @@ inline bool
HaikuOutput
::
Open
(
AudioFormat
&
audio_format
,
Error
&
error
)
{
status_t
err
;
*
format
=
media_multi_audio_format
::
wildcard
;
format
=
media_multi_audio_format
::
wildcard
;
switch
(
audio_format
.
format
)
{
case
SampleFormat
:
:
S8
:
format
->
format
=
media_raw_audio_format
::
B_AUDIO_CHAR
;
format
.
format
=
media_raw_audio_format
::
B_AUDIO_CHAR
;
break
;
case
SampleFormat
:
:
S16
:
format
->
format
=
media_raw_audio_format
::
B_AUDIO_SHORT
;
format
.
format
=
media_raw_audio_format
::
B_AUDIO_SHORT
;
break
;
case
SampleFormat
:
:
S32
:
format
->
format
=
media_raw_audio_format
::
B_AUDIO_INT
;
format
.
format
=
media_raw_audio_format
::
B_AUDIO_INT
;
break
;
case
SampleFormat
:
:
FLOAT
:
format
->
format
=
media_raw_audio_format
::
B_AUDIO_FLOAT
;
format
.
format
=
media_raw_audio_format
::
B_AUDIO_FLOAT
;
break
;
default
:
/* fall back to float */
audio_format
.
format
=
SampleFormat
::
FLOAT
;
format
->
format
=
media_raw_audio_format
::
B_AUDIO_FLOAT
;
format
.
format
=
media_raw_audio_format
::
B_AUDIO_FLOAT
;
break
;
}
format
->
frame_rate
=
audio_format
.
sample_rate
;
format
->
byte_order
=
B_MEDIA_HOST_ENDIAN
;
format
->
channel_count
=
audio_format
.
channels
;
format
.
frame_rate
=
audio_format
.
sample_rate
;
format
.
byte_order
=
B_MEDIA_HOST_ENDIAN
;
format
.
channel_count
=
audio_format
.
channels
;
buffer_size
=
0
;
if
(
write_size
)
format
->
buffer_size
=
write_size
;
format
.
buffer_size
=
write_size
;
else
format
->
buffer_size
=
BMediaRoster
::
Roster
()
->
AudioBufferSizeFor
(
format
->
channel_count
,
format
->
format
,
format
->
frame_rate
,
B_UNKNOWN_BUS
)
*
2
;
format
.
buffer_size
=
BMediaRoster
::
Roster
()
->
AudioBufferSizeFor
(
format
.
channel_count
,
format
.
format
,
format
.
frame_rate
,
B_UNKNOWN_BUS
)
*
2
;
FormatDebug
(
haiku_output_domain
,
"using haiku driver ad: bs: %d ws: %d "
"channels %d rate %f fmt %08lx bs %d
\n
"
,
(
int
)
buffer_size
,
(
int
)
write_size
,
(
int
)
format
->
channel_count
,
format
->
frame_rate
,
format
->
format
,
(
int
)
format
->
buffer_size
);
(
int
)
format
.
channel_count
,
format
.
frame_rate
,
format
.
format
,
(
int
)
format
.
buffer_size
);
sound_player
=
new
BSoundPlayer
(
format
,
"MPD Output"
,
sound_player
=
new
BSoundPlayer
(
&
format
,
"MPD Output"
,
fill_buffer
,
NULL
,
this
);
err
=
sound_player
->
InitCheck
();
...
...
@@ -293,11 +285,11 @@ HaikuOutput::Open(AudioFormat &audio_format, Error &error)
}
// calculate the allowable delay for the buffer (ms)
buffer_delay
=
format
->
buffer_size
;
buffer_delay
/=
(
format
->
format
&
buffer_delay
=
format
.
buffer_size
;
buffer_delay
/=
(
format
.
format
&
media_raw_audio_format
::
B_AUDIO_SIZE_MASK
);
buffer_delay
/=
format
->
channel_count
;
buffer_delay
*=
1000
/
format
->
frame_rate
;
buffer_delay
/=
format
.
channel_count
;
buffer_delay
*=
1000
/
format
.
frame_rate
;
// half of the total buffer play time
buffer_delay
/=
2
;
FormatDebug
(
haiku_output_domain
,
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment